/*
 * BanBu_PeopleDataController
 * @description 本文件提供个人空间的其他用户个人信息界面的ViewController
 * @package
 * @author 		***
 * @copyright
 * @version 		1.0
 * @description 本文件提供个人空间的其他用户个人信息界面的ViewController
 */

#import "BanBu_PeopleDataController.h"
#import "BanBu_ChatViewController.h"
//#import "BanBu_ListCellCell.h"
#import "UIBadgeView.h"
#import "TKLoadingView.h"
#import "BanBu_BlacklistViewController.h"
#import "BanBu_NavButton.h"
#import "BanBu_ImageView.h"
#import "BanBu_ThemeManager.h"
#import "UIMenuItem+CXAImageSupport.h"
#import "BanBu_HisFriendViewController.h"
#import "BanBu_BroadcastTVC.h"

#import "BanBu_VideoAuthenViewController.h"
#import "LeveyTabBarController.h"
#import "UIViewController+Animation.h"
#import "BanBu_VIPAlert.h"
#import "BanBu_MWNavigationController.h"
@interface BanBu_PeopleDataController ()
{
    BOOL isVerify;
    MWPhoto *verifyPhoto;
}
@end

@implementation BanBu_PeopleDataController

@synthesize profile = _profile;
@synthesize toolbarView = _toolbarView;

- (id)initWithProfile:(NSDictionary *)profileDic displayType:(DisplayType)type;
{
    self = [super initWithStyle:UITableViewStyleGrouped];
    if (self) {
        _profile = [[NSMutableDictionary alloc] initWithDictionary:profileDic];
        NSLog(@"%@",_profile);
    }
    return self;
}
-(void)setProfile:(NSDictionary *)profile
{
    [_profile removeAllObjects];
    [_profile addEntriesFromDictionary:profile];
    NSArray *grjsArr = [NSArray arrayWithObjects: @"liked" ,@"lovego" , @"company" , @"jobtitle" , @"school" , nil];
    NSArray *titleArr1 = [NSArray arrayWithObjects: NSLocalizedString(@"s2c0", nil),NSLocalizedString(@"s2c1", nil),NSLocalizedString(@"s2c2", nil),NSLocalizedString(@"s2c3", nil),NSLocalizedString(@"s2c4", nil), nil];
    grjsNum=0;
    for (int i=0; i<5; i++)
    {
        if([[_profile valueForKey:[grjsArr objectAtIndex:i]] length])
        {
            NSDictionary *aDic = [NSDictionary dictionaryWithObject:[_profile valueForKey:[grjsArr objectAtIndex:i]] forKey:[titleArr1 objectAtIndex:i]];
            [titleAndValueArr addObject:aDic];
            grjsNum++;
        }
    }
    grjsNum?(isHaveGRJS = YES):(isHaveGRJS = NO);
    self.title =  [MyAppDataManager IsInternationalLanguage:[MyAppDataManager theRevisedName:[_profile valueForKey:@"pname"] andUID:[_profile valueForKey:@"userid"]]];
    
    //    self.tableView.tableHeaderView = [BanBu_PeopleDataController creatHeaderView:_profile];
    
    [self.tableView reloadData];
    
}
-(void)pop
{
    [self.navigationController popViewControllerAnimated:YES];
}
-(void)changeTheme111
{
    NSArray *images = [NSArray arrayWithObjects:@"button_gochat.png",@"button_addfriend.png",@"button_block.png",@"button_delbuddy.png",nil];
    for(int i=0; i<3; i++)
    {
        UIButton *button = (UIButton *)[self.toolbarView viewWithTag:i+178];
        UIImage *image = [ThemeManager getThemeImage:[images objectAtIndex:i]];
        [button setBackgroundImage:image forState:UIControlStateNormal];
    }
}
#pragma mark - 加入黑名单
-(void)addBlack
{
    if(!_isBlack)
    {
        _isBlack = YES;
        NSString *action = @"black";
        NSMutableDictionary *pars = [NSMutableDictionary dictionary];
        [pars setValue:[_profile valueForKey:@"userid"] forKey:LinkTouID];
        [pars setValue:action forKey:Action];
        [AppComManager getBanBuData:BanBu_Set_Friend_Link par:pars delegate:self];
        self.navigationController.view.userInteractionEnabled = NO;
        [TKLoadingView showTkloadingAddedTo:self.navigationController.view title:NSLocalizedString(@"chuliNotice", nil) activityAnimated:YES];
    }
    else
    {
        [TKLoadingView showTkloadingAddedTo:self.navigationController.view  title:NSLocalizedString(@"pullBlackOK", nil) activityAnimated:NO duration:1.0];
    }
}

- (void)viewDidLoad
{
    [super viewDidLoad];
    
    BanBu_AppDelegate *ap = (BanBu_AppDelegate *)[UIApplication sharedApplication].delegate;
    _socialInfo = [[NSMutableDictionary alloc] initWithCapacity:0];
    [AppComManager getBanBuData:BanBu_Get_User_Sns_Idlist par:[NSDictionary dictionaryWithObjectsAndKeys:[_profile valueForKey:@"userid"],@"userid", nil] delegate:self];
    
    verifyPhoto = nil;
    isVerify = NO;
    isVerify = [[_profile valueForKey:@"verify"] boolValue];
    if([[_profile valueForKey:@"userid"] length])
    {
        NSMutableDictionary *parDic = [NSMutableDictionary dictionaryWithCapacity:2];
        [parDic setValue:[_profile valueForKey:@"userid"] forKey:@"frienduid"];
        NSDictionary *dic = [NSDictionary dictionaryWithDictionary:[MyAppDataManager getUserBaseDataWithKey:KeyLastSeeDynamicTime]];
        NSString *timeString = nil;
        if([[dic allKeys] indexOfObject:[_profile valueForKey:@"userid"]]!=NSNotFound&&[[dic valueForKey:[_profile valueForKey:@"userid"]] length])
        {
            timeString = [dic valueForKey:[_profile valueForKey:@"userid"]];
        }
        else
        {
            timeString = @"";
        }
        
        [parDic setValue:timeString forKey:@"fromtime"];
        //        NSLog(@"%@",parDic);
        [AppComManager getBanBuData:BanBu_Get_Actioncount_Byfuid_V2 par:parDic delegate:self];
    }
    
    
    
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(changeTheme111) name:kThemeDidChangeNotification object:nil];
    self.title =  [MyAppDataManager IsInternationalLanguage:[MyAppDataManager theRevisedName:[_profile valueForKey:@"pname"] andUID:[_profile valueForKey:@"userid"]]];
    NSMutableArray *arr = [[NSMutableArray alloc]initWithCapacity:1];
    self.userActions = arr;
    [arr release];
    
    BanBu_ImageView *backImage = [[[BanBu_ImageView alloc] initWithBackGroundImageType:UIImageViewCreatTypeTable] autorelease];
    [self.tableView setBackgroundView:backImage];
    
    self.tableView.backgroundColor = [UIColor colorWithRed:255.0/255 green:250.0/255 blue:240.0/255 alpha:1.0];
    
    //2014年09月28日16:20:14 修改个人空间下方3个按钮
    UIView *barView = [[UIView alloc] initWithFrame:CGRectMake(0, self.navigationController.view.frame.size.height + 20, 320, 44)];
    NSArray *titles = [NSArray arrayWithObjects:NSLocalizedString(@"writeMessage", nil),NSLocalizedString(@"addLink", nil),NSLocalizedString(@"pullBlackReport", nil),NSLocalizedString(@"delLink", nil), nil];
    
    NSArray *images = [NSArray arrayWithObjects:@"button_gochat.png",@"button_addfriend.png",@"button_block.png",@"button_delbuddy.png",nil];
    
    float x = 0;
    for(int i=0; i<3; i++)
    {
        UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
        UIImage *image = [ThemeManager getThemeImage:[images objectAtIndex:i]];
        
        button.frame = CGRectMake(x, 0,image.size.width, 44);
        button.tag = i+178;
        [button setBackgroundImage:image forState:UIControlStateNormal];
        [button addTarget:self action:@selector(action:) forControlEvents:UIControlEventTouchUpInside];
        [barView addSubview:button];
        x += image.size.width;
        
        UILabel *titleLabel = [[UILabel alloc]initWithFrame:CGRectMake(35, 10, 70, 20)];
        titleLabel.textAlignment = UITextAlignmentCenter;
        titleLabel.font = [UIFont boldSystemFontOfSize:15];
        titleLabel.backgroundColor = [UIColor clearColor];
        //        titleLabel.backgroundColor = [UIColor redColor];
        titleLabel.textColor = [UIColor whiteColor];
        //        button.titleLabel.backgroundColor = [UIColor redColor];
        titleLabel.text = [titles objectAtIndex:i];
        titleLabel.tag = i+235;
        [button addSubview:titleLabel];
        
        if(i == 0)
            _talkButton = button;
        if(i == 1)
            _linkButton = button;
    }
    
    self.toolbarView = barView;
    [self.navigationController.view addSubview:_toolbarView];
    [barView release];
    
    UIView *footer = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 320, 45)];
    footer.backgroundColor = [UIColor clearColor];
    self.tableView.tableFooterView = footer;
    [footer release];
    
    titleAndValueArr = [[NSMutableArray alloc]initWithCapacity:10];
    
    NSArray *grjsArr = [NSArray arrayWithObjects: @"liked" ,@"lovego" , @"company" , @"jobtitle" , @"school" , nil];
    NSArray *titleArr1 = [NSArray arrayWithObjects: NSLocalizedString(@"s2c0", nil),NSLocalizedString(@"s2c1", nil),NSLocalizedString(@"s2c2", nil),NSLocalizedString(@"s2c3", nil),NSLocalizedString(@"s2c4", nil), nil];
    grjsNum = 0;
    for (int i=0; i<5; i++) {
        if([[_profile valueForKey:[grjsArr objectAtIndex:i]] length]){
            NSDictionary *aDic = [NSDictionary dictionaryWithObject:[_profile valueForKey:[grjsArr objectAtIndex:i]] forKey:[titleArr1 objectAtIndex:i]];
            [titleAndValueArr addObject:aDic];
            grjsNum++;
        }
    }
    grjsNum?(isHaveGRJS = YES):(isHaveGRJS = NO);
    if([MyAppDataManager.useruid isEqualToString:[_profile valueForKey:@"userid"]]){
        _kind = 5;//自己
        return;
    }
    
    
    BOOL isLogin = ap.logined;
    if(!isLogin)
    {
        return;
    }
    
    NSString *searchStr = [NSString stringWithFormat:@",%@,",[_profile valueForKey:@"userid"]];
    if([[[[UserDefaults valueForKey:MyAppDataManager.useruid] valueForKey:FriendShip] valueForKey:@"x"] rangeOfString:searchStr].location!=NSNotFound&&[[[[UserDefaults valueForKey:MyAppDataManager.useruid] valueForKey:FriendShip] valueForKey:@"f"] rangeOfString:searchStr].location!=NSNotFound&&[[[[UserDefaults valueForKey:MyAppDataManager.useruid] valueForKey:FriendShip] valueForKey:@"g"] rangeOfString:searchStr].location!=NSNotFound)
    {
        _kind = 4;
        return;
    }
    NSString *fensi = [[[UserDefaults valueForKey:MyAppDataManager.useruid]valueForKey:FriendShip] valueForKey:@"f"];
    NSString *guanzhu = [[[UserDefaults valueForKey:MyAppDataManager.useruid]valueForKey:FriendShip] valueForKey:@"g"];
    NSString *friend = [[[UserDefaults valueForKey:MyAppDataManager.useruid]valueForKey:FriendShip] valueForKey:@"h"];
    NSString *black = [[[UserDefaults valueForKey:MyAppDataManager.useruid]valueForKey:FriendShip] valueForKey:@"x"];
    //    NSLog(@"friend : %@",friend);
    NSLog(@"%@",[_profile valueForKey:@"userid"]);
    //    NSLog(@"FriendShip : %@",[[UserDefaults valueForKey:MyAppDataManager.useruid]valueForKey:FriendShip]);
    if([friend rangeOfString:[_profile valueForKey:@"userid"]].location != NSNotFound)
    {
        _linked = YES;
        _kind = 2;//好友
    }
    
    else if([guanzhu rangeOfString:[_profile valueForKey:@"userid"]].location != NSNotFound)
    {
        _linked = YES;
        _kind = 0;//关注
    }
    else if([fensi rangeOfString:[_profile valueForKey:@"userid"]].location != NSNotFound)
    {
        _linked = NO;
        _kind = 1;//粉丝
    }
    else if([black rangeOfString:[_profile valueForKey:@"userid"]].location != NSNotFound)
    {
        _linked = NO;
        _kind = 3;//黑名单
    }
    else
    {
        _linked = NO;
        _kind = 4;//陌生人
    }
    
    [_linkButton setBackgroundImage:_linked?[ThemeManager getThemeImage: @"button_delbuddy.png"]:[ThemeManager getThemeImage:@"button_addfriend.png"] forState:UIControlStateNormal];
    [(UILabel *)[_linkButton viewWithTag:236] setText:_linked?[titles objectAtIndex:3]:[titles objectAtIndex:1]];
    //声明看过此人(偷偷的)
    //7.25修改看过五个非本人异性才提交
    NSMutableDictionary *userHaveSeen = [NSMutableDictionary dictionaryWithDictionary:[MyAppDataManager getUserBaseDataWithKey:keyUserHaveSeen]];
    
    
    NSMutableString *usersString = [[[NSMutableString alloc]init]autorelease];
    if([[userHaveSeen valueForKey:@"users"] length])[usersString appendString:[userHaveSeen valueForKey:@"users"]];
    NSLog(@"已经看过、三天不提交的人%@ 是否添加这个人%@%d",userHaveSeen,[_profile valueForKey:@"userid"],_kind!=2&&![[[UserDefaults valueForKey:MyAppDataManager.useruid] valueForKey:@"userid"] isEqual:[_profile valueForKey:@"userid"]]&&[[_profile valueForKey:@"userid"] length]&&([usersString rangeOfString:[NSString stringWithFormat:@",%@,",[_profile valueForKey:@"userid"]]].location==NSNotFound||!usersString.length));
    if(_kind!=2&&![[[UserDefaults valueForKey:MyAppDataManager.useruid] valueForKey:@"userid"] isEqual:[_profile valueForKey:@"userid"]]&&[[_profile valueForKey:@"userid"] length]&&([usersString rangeOfString:[NSString stringWithFormat:@",%@,",[_profile valueForKey:@"userid"]]].location==NSNotFound||!usersString.length))
    {
        
        NSLog(@"%@",MyAppDataManager.peopleReaded);
        [MyAppDataManager.peopleReaded setObject:[NSNumber numberWithBool:YES] forKey:[_profile valueForKey:@"userid"]];
        if(!usersString.length){[usersString appendString:[NSString stringWithFormat:@",%@,",[_profile valueForKey:@"userid"]]];}
        else {[usersString appendString:[NSString stringWithFormat:@"%@,",[_profile valueForKey:@"userid"]]];}
        
        [userHaveSeen setValue:usersString forKey:@"users"];
        NSLog(@"添加上、、%@",usersString);
        [MyAppDataManager modifyUserBaseDataWithKey:keyUserHaveSeen andData:userHaveSeen];
        
        if(MyAppDataManager.peopleReaded.count>=5)
        {
            NSLog(@"五个人开始提交%@",MyAppDataManager.peopleReaded);
            NSArray *keys = MyAppDataManager.peopleReaded.allKeys;
            NSString *uidList = [keys componentsJoinedByString:@","];
            NSDictionary *parDic = [NSDictionary dictionaryWithObjectsAndKeys:uidList,@"useridlist",nil];
            [AppComManager getBanBuData:BanBu_Set_User_View par:parDic delegate:MyAppDataManager];
        }
        else
        {
            [UserDefaults setValue:MyAppDataManager.peopleReaded forKey:@"peopleReaded"];
        }
    }
    
    
    UIMenuItem *textItem = [[[UIMenuItem alloc] initWithTitle:NSLocalizedString(@"copyButton", nil) action:@selector(copyAction)] autorelease];
    [UIMenuController sharedMenuController].menuItems = @[textItem];
    
    //气泡初始化
    _badgeView = [[UIBadgeView alloc] init];
    _badgeView.backgroundColor = [UIColor clearColor];
    _badgeView.badgeColor = [UIColor redColor];
    [self.navigationItem.rightBarButtonItem.customView addSubview:_badgeView];
    
}
-(void)viewWillAppear:(BOOL)animated
{
    [UIView setAnimationsEnabled:YES];
    [super viewWillAppear:animated];
}
-(void)popself
{
    [self.navigationController popViewControllerAnimated:YES];
}
- (void)viewDidAppear:(BOOL)animated
{
    [super viewDidAppear:animated];
    [self.leveyTabBarController hidesTabBar:YES animated:YES];
    
    //2014年09月28日16:17:55 隐藏 by yinlinlin,修改个人空间下方3个按钮
    //    if(_kind != 5){
    //        [UIView animateWithDuration:0.5
    //                         animations:^{
    //                             CGRect rect = _toolbarView.frame;
    //                             rect.origin.y -= 64;
    //                             _toolbarView.frame = rect;
    //                         }];
    //    }else{
    //        UIView *footer = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 320, 1)];
    //        footer.backgroundColor = [UIColor clearColor];
    //        self.tableView.tableFooterView = footer;
    //        [footer release];
    //    }
    
}

- (void)viewWillDisappear:(BOOL)animated
{
    [super viewWillDisappear:animated];
    [TKLoadingView dismissTkFromView:self.navigationController.view animated:YES afterShow:0];
    //2014年09月28日16:17:55 隐藏 by yinlinlin 修改个人空间下方3个按钮
    //    [UIView animateWithDuration:0.5
    //                     animations:^{
    //                         CGRect rect = _toolbarView.frame;
    //                         rect.origin.y += 64;
    //                         _toolbarView.frame = rect;
    //                     }];
    //    [AppComManager cancalHandlesForObject:self];
}
- (void)viewDidUnload
{
    [super viewDidUnload];
    self.profile = nil;
    //    _success =NO;
    [_toolbarView removeFromSuperview];
    self.toolbarView = nil;
    //    _photoView = nil;
}

- (void)dealloc
{
    [AppComManager cancalHandlesForObject:self];
    //    [[NSNotificationCenter defaultCenter]removeObserver:self name:kThemeDidChangeNotification object:nil];
    
    [_socialInfo release],_socialInfo = nil;
    [titleAndValueArr release],titleAndValueArr = nil;
    [_badgeView release],_badgeView = nil;
    [_toolbarView removeFromSuperview];
    [_toolbarView release],_toolbarView = nil;
    [_profile release], _profile = nil;
    if(verifyPhoto)
    {
        [verifyPhoto release],verifyPhoto = nil;
    }
    //    [aNC release], aNC = nil;
    //    [_photoView release], _photoView = nil;
    [super dealloc];
}

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    return (interfaceOrientation == UIInterfaceOrientationPortrait);
}


-(void)sendMessageTochat{
    NSLog(@"sd");
}

#pragma mark - Table view data source

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    return isHaveGRJS?5:4;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    
    if(isHaveGRJS){
        if(section == 0){
            return 2;
        }else if(section == 1){
            return 4;
        }
        else if(section == 2){
            return 4;
        }else if(section == 3){
            
            //NSLog(@"%d",grjsNum);
            return grjsNum+1;
        }else{
            return 5;
        }
    }else{
        if(section == 0){
            return 2;
        }else if(section == 1){
            return 4;
        }
        else if(section == 2){
            return 4;
        }else{
            return 5;
        }
    }
    
}
//-(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
//{
//    return 25;
//}
//- (float)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section
//{
//        if(isHaveGRJS){
//            if(section ==(4)){
//                return 0;
//            }else{
//                return 50;
//            }
//        }
//        else{
//            if(section ==(3) ){
//                return 0;
//            }else{
//                return 50;
//            }
//        }
//}
//
//- (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section
//{
//    if(section == 4)
//        return nil;
//    UIView  *aView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, 320, 50)];
//    UILabel *titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 320, 50)];
//    titleLabel.textColor = [UIColor colorWithRed:56.0/255 green:84.0/255 blue:135.0/255 alpha:1.0];
//    titleLabel.backgroundColor = [UIColor clearColor];
//    BanBu_ImageView *img = [[BanBu_ImageView alloc] initWithBackGroundImageType:UIImageViewCreatTypeCell];
//
//    if(!img.image)
//    {
//        titleLabel.backgroundColor = [UIColor lightGrayColor];
//
//    }
//    img.frame = CGRectMake(0, 0, 320, 50);
//    [aView addSubview:img];
//    [aView addSubview:titleLabel];
//    [titleLabel release];
//    [img release];
//
//
//    titleLabel.font = [UIFont boldSystemFontOfSize:14];
//    if(isHaveGRJS){
//        if(section == 0)
//            titleLabel.text= NSLocalizedString(@"socialNetwork", nil);
//        else if(section == 1)
//            titleLabel.text= NSLocalizedString(@"profileSection", nil);
//        else if(section == 2)
//            titleLabel.text= NSLocalizedString(@"profileSection1", nil);
//        else if(section == 3)
//            titleLabel.text= NSLocalizedString(@"profileSection3", nil);
//        else
//            return nil;
//    }
//    else
//    {
//        if(section == 0)
//            titleLabel.text= NSLocalizedString(@"socialNetwork", nil);
//        else if(section == 1)
//            titleLabel.text= NSLocalizedString(@"profileSection", nil);
//
//        else if(section == 2)
//            titleLabel.text= NSLocalizedString(@"profileSection3", nil);
//        else
//        {
//            [aView release];
//            return nil;
//
//        }
//
//    }
//    return [aView autorelease];
//}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    if(indexPath.row == 0)
    {
        return 50;
    }
    //    if(indexPath.section == 1&&indexPath.row == 1)
    //    {
    //        return 80;
    //    }
    NSInteger row = indexPath.row-1;
    if(indexPath.section == 0)
    {
        if(!row)
        {
            NSString *detailValue = [_profile valueForKey:@"sayme"];
            //                if(!detailValue.length)
            //                {
            //                    detailValue = NSLocalizedString(@"nosignature", nil);
            //                }
            if([detailValue stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]].length)
            {
                return  [detailValue sizeWithFont:[UIFont systemFontOfSize:14] constrainedToSize:CGSizeMake(260, 1000)].height+30;
                
            }
            else{
                return  40;
            }
        }
        
        
    }
    else{
        
        if(indexPath.section == 3)
        {
            if(isHaveGRJS){
                //                    NSArray *keyValue = [NSArray arrayWithObjects:@"liked",@"company",@"school",@"lovego",@"jobtitle", nil];
                NSString * detailValue =  [[[titleAndValueArr objectAtIndex:row] allValues] objectAtIndex:0];
                
                return  [detailValue sizeWithFont:[UIFont systemFontOfSize:14] constrainedToSize:CGSizeMake(260, 1000)].height+40;
            }
            else{
                //                    if(row == 0)
                //                    {
                return 90;
                //                    }
                //                    return  40;
            }
            
        }
        else  if(indexPath.section == 4)
        {
            return  90;
        }
        
    }
    return  40 ;
}
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
    if(section == 0)
    {
        return 0;
    }
    return 10;
}

- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section {
    if(section == 0)
    {
        return nil;
    }
    UIView *view=[[UIView alloc] initWithFrame:CGRectMake(0, 0, 320, 10)];
    view.backgroundColor = [UIColor clearColor];//根据需求改变着个颜色不需要改为clear
    return [view autorelease];
}
-(void)inviteVerify
{
    [AppComManager getBanBuData:BanBu_Send_Verify_Invite_Touser par:[NSDictionary dictionaryWithObjectsAndKeys:[_profile valueForKey:@"userid"],@"userid", nil] delegate:self];
}

-(CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section{
    
    return 10;
}
-(UIView*)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section{
    if(section == 0)
    {
        return nil;
    }
    UIView *view=[[UIView alloc] initWithFrame:CGRectMake(0, 0, 320, 10)];
    view.backgroundColor = [UIColor clearColor];//根据需求改变着个颜色不需要改为clear
    return [view autorelease];
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    isVerify = [[_profile valueForKey:@"verify"] boolValue];
    if(indexPath.row == 0)
    {
        static NSString *cellIndentifierrr = @"111111";
        UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIndentifierrr];
        if(!cell)
        {
            cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:cellIndentifierrr] autorelease];
            [cell setSelectionStyle:UITableViewCellSelectionStyleNone];
            cell.backgroundColor = [UIColor whiteColor];
        }
        else
        {
            for(UIView *v in cell.contentView.subviews)
            {
                [v removeFromSuperview];
            }
            cell.detailTextLabel.text = @"";
            cell.textLabel.text = @"";
            
        }
        
        UILabel *lab = [[UILabel alloc] initWithFrame:CGRectMake(30, 1, 250, 48)];
        lab.font = [UIFont boldSystemFontOfSize:16];
        lab.numberOfLines = 1;
        lab.textColor = [UIColor colorWithWhite:0.349 alpha:1.000];
        [cell.contentView addSubview:lab];
        [lab release];
        
        UIImageView *img = [[UIImageView alloc] initWithFrame:CGRectMake(10, 12, 25, 25)];
        [cell.contentView addSubview:img];
        [img release];
        if(indexPath.section == 0)
        {
            lab.text= [@"  " stringByAppendingString:NSLocalizedString(@"s0c2", nil)];
            img.image = [UIImage imageNamed:@"gerenqianming.png"];
        }
        else if(indexPath.section == 1)
        {
            lab.text= NSLocalizedString(@"profileSection3", nil);
            img.image = [UIImage imageNamed:@"zhanghaoxinxi.png"];
            
            
        }
        else if(indexPath.section == 2)
        {
            lab.text= NSLocalizedString(@"profileSection", nil);
            img.image = [UIImage imageNamed:@"jibenxinxi.png"];
        }
        else if(indexPath.section == 3)
        {
            if(isHaveGRJS)
            {
                lab.text= NSLocalizedString(@"profileSection1", nil);
                img.image = [UIImage imageNamed:@"gerenxinxi.png"];
            }
            else
            {
                lab.text= NSLocalizedString(@"socialNetwork", nil);
                img.image = [UIImage imageNamed:@"shejiaowangluo.png"];
            }
            
        }
        else if(indexPath.section == 4)
        {
            lab.text= NSLocalizedString(@"socialNetwork", nil);
            img.image = [UIImage imageNamed:@"shejiaowangluo.png"];
        }
        return cell;
        
        
    }
    
    NSInteger row = indexPath.row-1;
    
    
    //    static NSString *CellIdentifier = @"      ";
    BOOL showType;
    if(isHaveGRJS)
    {
        if(indexPath.section == 0 || indexPath.section == 3){
            showType = YES;
        }else{
            showType = NO;
        }
    }
    else
    {
        if(indexPath.section){
            showType = NO;
        }else{
            showType = YES;
        }
    }
    static NSString *CellIdentifier1 = @"ProfileCellIdentifier11111";
    static NSString *CellIdentifier2 = @"ProfileCellIdentifier22222";
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:showType?CellIdentifier1:CellIdentifier2];
    if(!cell)
    {
        cell = [[[UITableViewCell alloc] initWithStyle:showType?UITableViewCellStyleSubtitle:UITableViewCellStyleValue1 reuseIdentifier:showType?CellIdentifier1:CellIdentifier2] autorelease];
        cell.backgroundColor = [UIColor whiteColor];
        cell.detailTextLabel.numberOfLines = 0;
        cell.detailTextLabel.font = [UIFont systemFontOfSize:14];
        cell.detailTextLabel.textColor = [UIColor colorWithWhite:0.399 alpha:1.000];
        cell.textLabel.font = [UIFont boldSystemFontOfSize:16];
        UILongPressGestureRecognizer *gesture = [[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(copyInfo:)];
        [gesture setMinimumPressDuration:1];
        [cell addGestureRecognizer:gesture];
        [gesture release];
        [cell setSelectionStyle:UITableViewCellSelectionStyleNone];
    }
    else
    {
        for(UIView *v in cell.contentView.subviews)
        {
            [v removeFromSuperview];
        }
        cell.detailTextLabel.text = @"";
        cell.textLabel.text = @"";
        cell.textLabel.textColor = [UIColor blackColor];
        cell.detailTextLabel.textColor = [UIColor colorWithWhite:0.399 alpha:1.000];
    }
    
    
    if ([tableView respondsToSelector:@selector(setSeparatorInset:)]&&IS_IOS_7)
    {
        [tableView setSeparatorInset:UIEdgeInsetsMake(0, 45, 0, 0)];
    }
    
    if(isHaveGRJS)
    {
        if(indexPath.section)
        {
            if(indexPath.section == 4)
            {
                cell.textLabel.text = @"";
                cell.detailTextLabel.text = @"";
                NSArray *netImageArr= nil;
                NSArray *nameArr = nil;
                NSArray *paramArr = nil;
                
                if([[MyAppDataManager getLanguageSubmitToServer] isEqualToString:@"cn"])
                {
                    netImageArr = [NSArray arrayWithObjects:@"sina_social.png",@"tencent_social.png",@"weichat_social.png",@"momo_social.png", nil];
                    nameArr     = [NSArray arrayWithObjects:@"新浪微博",@"腾讯微博",@"微信",@"陌陌",nil];
                    paramArr = [NSArray arrayWithObjects:@"sina",@"tencent",@"wechat",@"momo",nil];
                    
                    
                }
                else if([[MyAppDataManager getLanguageSubmitToServer] isEqualToString:@"jp"])
                {
                    netImageArr = [NSArray arrayWithObjects:@"fb_social.png",@"twiter_social.png",@"line_social.png",@"kakao_social.png", nil];
                    nameArr     = [NSArray arrayWithObjects:@"Facebook",@"Twitter",@"LINE",@"Kakao",nil];
                    paramArr = [NSArray arrayWithObjects:@"facebook",@"twitter",@"line",@"kakao",nil];
                    
                }
                else
                {
                    netImageArr = [NSArray arrayWithObjects:@"fb_social.png",@"twiter_social.png",@"instagram_social.png",@"kik_social.png", nil];
                    nameArr     = [NSArray arrayWithObjects:@"Facebook",@"Twitter",@"Instagram",@"Kik",nil];
                    paramArr = [NSArray arrayWithObjects:@"facebook",@"twitter",@"instagram",@"kik",nil];
                    
                }
                UIImageView *img = [[UIImageView alloc] initWithImage:[UIImage imageNamed:[netImageArr objectAtIndex:row]]];
                img.frame = CGRectMake(45, 10, 50, 50);
                [cell.contentView addSubview:img];
                [img release];
                
                if(![[_socialInfo  valueForKey:[paramArr objectAtIndex:row]] length])
                {
                    cell.detailTextLabel.text = NSLocalizedString(@"noAdd", nil);
                }
                else
                {
                    cell.detailTextLabel.text = [_socialInfo valueForKey:[paramArr objectAtIndex:row]];
                }
                
                
                UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(40, 65, 60, 15)];
                label.backgroundColor = [UIColor clearColor];
                label.font = [UIFont systemFontOfSize:13];
                label.text = [nameArr objectAtIndex:row];
                label.textAlignment = kTextAlignmentCenter;
                [cell.contentView addSubview:label];
                [label release];
                return cell;
                
            }
            if (indexPath.section == 2)
            {
                if(row == 0){
                    cell.textLabel.text = NSLocalizedString(@"s1c0", nil);
                    if(![[_profile valueForKey:@"hbody"] isEqualToString:@"-"]){
                        cell.detailTextLabel.text = [_profile valueForKey:@"hbody"];
                    }else{
                        cell.detailTextLabel.text =@"<160";
                    }
                }else if(row == 1){
                    cell.textLabel.text = NSLocalizedString(@"s1c1", nil);
                    if(![[_profile valueForKey:@"xblood"] isEqualToString:@""]){
                        cell.detailTextLabel.text = [_profile valueForKey:@"xblood"];
                    }else{
                        cell.detailTextLabel.text =@"A";
                    }
                }
                else if(row == 2){
                    cell.textLabel.text = NSLocalizedString(@"s1c2", nil);
                    if(![[_profile valueForKey:@"wbody"] isEqualToString:@"-"]){
                        cell.detailTextLabel.text = [_profile valueForKey:@"wbody"];
                    }else{
                        cell.detailTextLabel.text =@"<40";
                    }                    }
            }
            else if(indexPath.section == 3)
            {
                cell.textLabel.text = [[[titleAndValueArr objectAtIndex:row] allKeys] objectAtIndex:0];
                cell.detailTextLabel.font =  [UIFont systemFontOfSize:14];
                cell.detailTextLabel.text =  [[[titleAndValueArr objectAtIndex:row] allValues] objectAtIndex:0];
            }
            else if(indexPath.section == 1)
            {
                if(row == 0)
                {
                    cell.textLabel.text = NSLocalizedString(@"s0c0", nil);
                    cell.detailTextLabel.text = [_profile valueForKey:@"userid"];
                }
                else if(row == 1)
                {
                    NSArray *frindshipArr = [NSArray arrayWithObjects:NSLocalizedString(@"friendShip", nil),NSLocalizedString(@"friendShip1", nil),NSLocalizedString(@"friendShip2", nil),NSLocalizedString(@"friendShip3", nil),NSLocalizedString(@"friendShip4", nil),NSLocalizedString(@"friendShip5", nil), nil];
                    cell.textLabel.text = NSLocalizedString(@"relationshipLabel", nil);
                    cell.detailTextLabel.font =  [UIFont systemFontOfSize:14];
                    
                    cell.detailTextLabel.text =  [frindshipArr objectAtIndex:_kind];
                }
                else
                {
                    
                    if(![[_profile valueForKey:@"verify"] isEqual:@"y"])
                    {
                        cell.detailTextLabel.textColor = [UIColor redColor];
                        cell.textLabel.textColor = [UIColor redColor];
                        cell.textLabel.text = NSLocalizedString(@"videoVerifyUncomplete", nil);
                        cell.detailTextLabel.text = NSLocalizedString(@"inviteVerify", nil);
                        
                        UIButton *inviteBtn = [UIButton buttonWithType:UIButtonTypeCustom];
                        inviteBtn.frame = CGRectMake(220, 5, 80, 30);
                        //                        [inviteBtn setBackgroundImage:[[ThemeManager getThemeImage:@"app_btn_blue.png"] stretchableImageWithLeftCapWidth:10.0 topCapHeight:0.0] forState:UIControlStateNormal];
                        inviteBtn.backgroundColor = [UIColor clearColor];
                        //                        [inviteBtn setTitle:NSLocalizedString(@"inviteVerify", nil) forState:UIControlStateNormal];
                        [inviteBtn addTarget:self action:@selector(inviteVerify) forControlEvents:UIControlEventTouchUpInside];
                        [cell.contentView addSubview:inviteBtn];
                    }
                    else
                    {
                        cell.textLabel.text = NSLocalizedString(@"videoVerify", nil);
                        UIImageView *yImage = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"isVerified.png"]];
                        yImage.frame = CGRectMake(__MainScreen_Width-10-10-20-40, 10, 20, 20);
                        [cell.contentView addSubview:yImage];
                        [yImage release];
                        
                        UIImageView *img = [[UIImageView alloc] init];
                        [img setImageWithURL:[NSURL URLWithString:[_profile valueForKey:@"image_verify"]] placeholderImage:[UIImage imageNamed:@"default.png"] andType:0];
                        img.frame = CGRectMake(__MainScreen_Width-10-10-10, 15, 20, 20);
                        img.center = CGPointMake(__MainScreen_Width-10-20-10, 20);
                        [cell.contentView addSubview:img];
                        [img release];
                    }
                    
                }
            }
        }
        else
        {
            if(row)
            {
                
            }
            else
            {
                //                id faces = [_profile valueForKey:@"facelist"];
                //                if([faces isKindOfClass:[NSArray class]])
                //                {
                //                    if([faces count])
                //                    {
                //                        _photoView.myPhotos = faces;
                //
                //                    }
                //                    else
                //                    {
                //
                //                    }
                //                }
                //                cell.textLabel.text = NSLocalizedString(@"s0c2", nil);
                cell.detailTextLabel.font =  [UIFont systemFontOfSize:14];
                cell.detailTextLabel.text =  [_profile valueForKey:@"sayme"];
                //                if(![[_profile valueForKey:@"sayme"] length])
                //                {
                //                    cell.detailTextLabel.text = NSLocalizedString(@"nosignature", nil);
                //                }
            }
        }
    }
    else
    {
        if(indexPath.section)
        {
            if(indexPath.section == 3)
            {
                
                
                cell.textLabel.text = @"";
                cell.detailTextLabel.text = @"";
                NSArray *netImageArr= nil;
                NSArray *nameArr = nil;
                NSArray *paramArr = nil;
                
                if([[MyAppDataManager getLanguageSubmitToServer] isEqualToString:@"cn"])
                {
                    netImageArr = [NSArray arrayWithObjects:@"sina_social.png",@"tencent_social.png",@"weichat_social.png",@"momo_social.png", nil];
                    nameArr     = [NSArray arrayWithObjects:@"新浪微博",@"腾讯微博",@"微信",@"陌陌",nil];
                    paramArr = [NSArray arrayWithObjects:@"sina",@"tencent",@"wechat",@"momo",nil];
                    
                    
                }
                else if([[MyAppDataManager getLanguageSubmitToServer] isEqualToString:@"jp"])
                {
                    netImageArr = [NSArray arrayWithObjects:@"fb_social.png",@"twiter_social.png",@"line_social.png",@"kakao_social.png", nil];
                    nameArr     = [NSArray arrayWithObjects:@"Facebook",@"Twitter",@"LINE",@"Kakao",nil];
                    paramArr = [NSArray arrayWithObjects:@"facebook",@"twitter",@"line",@"kakao",nil];
                    
                }
                else
                {
                    netImageArr = [NSArray arrayWithObjects:@"fb_social.png",@"twiter_social.png",@"instagram_social.png",@"kik_social.png", nil];
                    nameArr     = [NSArray arrayWithObjects:@"Facebook",@"Twitter",@"Instagram",@"Kik",nil];
                    paramArr = [NSArray arrayWithObjects:@"facebook",@"twitter",@"instagram",@"kik",nil];
                    
                }
                UIImageView *img = [[UIImageView alloc] initWithImage:[UIImage imageNamed:[netImageArr objectAtIndex:row]]];
                img.frame = CGRectMake(45, 10, 50, 50);
                [cell.contentView addSubview:img];
                [img release];
                
                if(![[_socialInfo  valueForKey:[paramArr objectAtIndex:row]] length])
                {
                    cell.detailTextLabel.text = NSLocalizedString(@"noAdd", nil);
                }
                else
                {
                    cell.detailTextLabel.text = [_socialInfo  valueForKey:[paramArr objectAtIndex:row]];
                }
                
                
                UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(40, 65, 60, 15)];
                label.backgroundColor = [UIColor clearColor];
                label.font = [UIFont systemFontOfSize:13];
                label.text = [nameArr objectAtIndex:row];
                label.textAlignment = kTextAlignmentCenter;
                [cell.contentView addSubview:label];
                [label release];
                return cell;
                
            }
            else if (indexPath.section == 2)
            {
                if(row == 0){
                    cell.textLabel.text = NSLocalizedString(@"s1c0", nil);
                    //                        //NSLog(@"%@",[_profile valueForKey:@"hbody"]);
                    if(![[_profile valueForKey:@"hbody"] isEqualToString:@""]){
                        cell.detailTextLabel.text = [_profile valueForKey:@"hbody"];
                    }else{
                        cell.detailTextLabel.text =@"<160";
                    }
                }else if(row == 1){
                    cell.textLabel.text = NSLocalizedString(@"s1c1", nil);
                    if(![[_profile valueForKey:@"xblood"] isEqualToString:@""]){
                        cell.detailTextLabel.text = [_profile valueForKey:@"xblood"];
                    }else{
                        cell.detailTextLabel.text =@"A";
                    }
                }else if(row == 2){
                    cell.textLabel.text = NSLocalizedString(@"s1c2", nil);
                    if(![[_profile valueForKey:@"wbody"] isEqualToString:@""]){
                        cell.detailTextLabel.text = [_profile valueForKey:@"wbody"];
                    }else{
                        cell.detailTextLabel.text =@"<40";
                    }                    }
            }
            else if(indexPath.section == 1)
            {
                
                if(row == 0)
                {
                    cell.textLabel.text = NSLocalizedString(@"s0c0", nil);
                    cell.detailTextLabel.text = [_profile valueForKey:@"userid"];
                }
                else if(row == 1)
                {
                    NSArray *frindshipArr = [NSArray arrayWithObjects:NSLocalizedString(@"friendShip", nil),NSLocalizedString(@"friendShip1", nil),NSLocalizedString(@"friendShip2", nil),NSLocalizedString(@"friendShip3", nil),NSLocalizedString(@"friendShip4", nil),NSLocalizedString(@"friendShip5", nil), nil];
                    cell.textLabel.text = NSLocalizedString(@"relationshipLabel", nil);
                    cell.detailTextLabel.text =  [frindshipArr objectAtIndex:_kind];
                }
                else
                {
                    
                    if(![[_profile valueForKey:@"verify"] isEqual:@"y"])
                    {
                        cell.detailTextLabel.textColor = [UIColor redColor];
                        cell.textLabel.textColor = [UIColor redColor];
                        cell.textLabel.text = NSLocalizedString(@"videoVerifyUncomplete", nil);
                        cell.detailTextLabel.text = NSLocalizedString(@"inviteVerify", nil);
                        
                        UIButton *inviteBtn = [UIButton buttonWithType:UIButtonTypeCustom];
                        inviteBtn.frame = CGRectMake(220, 5, 80, 30);
                        //                        [inviteBtn setBackgroundImage:[[ThemeManager getThemeImage:@"app_btn_blue.png"] stretchableImageWithLeftCapWidth:10.0 topCapHeight:0.0] forState:UIControlStateNormal];
                        inviteBtn.backgroundColor = [UIColor clearColor];
                        //                        [inviteBtn setTitle:NSLocalizedString(@"inviteVerify", nil) forState:UIControlStateNormal];
                        [inviteBtn addTarget:self action:@selector(inviteVerify) forControlEvents:UIControlEventTouchUpInside];
                        [cell.contentView addSubview:inviteBtn];
                    }
                    else
                    {
                        cell.textLabel.text = NSLocalizedString(@"videoVerify", nil);
                        UIImageView *yImage = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"isVerified.png"]];
                        yImage.frame = CGRectMake(__MainScreen_Width-10-10-20-40, 10, 20, 20);
                        [cell.contentView addSubview:yImage];
                        [yImage release];
                        
                        UIImageView *img = [[UIImageView alloc] init];
                        [img setImageWithURL:[NSURL URLWithString:[_profile valueForKey:@"image_verify"]] placeholderImage:[UIImage imageNamed:@"default.png"] andType:0];
                        img.frame = CGRectMake(__MainScreen_Width-10-10-10, 15, 20, 20);
                        img.center = CGPointMake(__MainScreen_Width-10-20-10, 20);
                        [cell.contentView addSubview:img];
                        [img release];
                    }
                    
                }
            }
        }
        else
        {
            if(row)
            {
            }
            else
            {
                //                id faces = [_profile valueForKey:@"facelist"];
                //                if([faces isKindOfClass:[NSArray class]])
                //                {
                //                    if([faces count])
                //                    {
                //                        _photoView.myPhotos = faces;
                //
                //                    }
                //                    else
                //                    {
                //
                //                    }
                //                }
                //                //                cell.textLabel.text = NSLocalizedString(@"s0c2", nil);
                cell.detailTextLabel.font =  [UIFont systemFontOfSize:14];
                cell.detailTextLabel.text =  [_profile valueForKey:@"sayme"];
                //                if(![[_profile valueForKey:@"sayme"] length])
                //                {
                //                    cell.detailTextLabel.text = NSLocalizedString(@"nosignature", nil);
                //                }
            }
        }
    }
    
    //    cell.detailTextLabel.textColor = [UIColor colorWithRed:56.0/255 green:84.0/255 blue:135.0/255 alpha:1.0];
    
    
    
    cell.selectionStyle = UITableViewCellSelectionStyleNone;
    
    
    return cell;
}
-(void)copyInfo:(UILongPressGestureRecognizer *)_gesture
{
    [[UIMenuController sharedMenuController] setTargetRect:self.view.frame inView:_gesture.view];
    [[UIMenuController sharedMenuController] setMenuVisible:YES animated:YES];
    copyCell  =  (UITableViewCell *)_gesture.view;
    
}
-(BOOL)canPerformAction:(SEL)action withSender:(id)sender
{
    if(action == @selector(copyAction))
        return YES;
    return [super canPerformAction:action withSender:sender];
}
-(void)copyAction
{
    UIPasteboard *pasteboard = [UIPasteboard generalPasteboard];
    
    pasteboard.string = copyCell.detailTextLabel.text;
}
- (BOOL)canBecomeFirstResponder
{
    return YES;
}
- (NSUInteger)numberOfPhotosInPhotoBrowser:(MWPhotoBrowser *)photoBrowser {
    return 1;
}

- (MWPhoto *)photoBrowser:(MWPhotoBrowser *)photoBrowser photoAtIndex:(NSUInteger)index {
    //    if (index < _showPhotos.count)
    return verifyPhoto;
    return nil;
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    NSInteger row = indexPath.row-1;
    BOOL selfVerify = [[[UserDefaults valueForKey:MyAppDataManager.useruid] valueForKey:@"verify"] boolValue];
    if(row == 2&&indexPath.section == 1&&isVerify)
    {
        if(selfVerify)
        {
            MWPhotoBrowser *browser = [[MWPhotoBrowser alloc] initWithDelegate:self];
            [browser setInitialPageIndex:0];
            browser.titleString  = NSLocalizedString(@"videoVerify", nil);
            verifyPhoto = [[MWPhoto photoWithURL:[NSURL URLWithString:[_profile valueForKey:@"image_verify"]]] retain];
            
            BanBu_MWNavigationController *nc = [[BanBu_MWNavigationController alloc] initWithRootViewController:browser];
            [self presentViewController:nc animated:YES];
            [nc release];
            [browser release];
        }
        else
        {
            
            [[BanBu_VIPAlert shareInstance] GoVerifyApplyViewAlertFor:self title:NSLocalizedString(@"videoVerify", nil) message:NSLocalizedString(@"goVideoVerifyNotice", nil)];
        }
        
    }
}

#pragma mark - 发起对话，关注，黑名单按钮
- (void)action:(UIButton *)button
{
    if((button.tag-178) == 2)
    {
        UIActionSheet *blockSheet;
        if(_kind == 2||_kind == 0){
            blockSheet = [[UIActionSheet alloc]
                          initWithTitle:nil
                          delegate:self
                          cancelButtonTitle:NSLocalizedString(@"cancelNotice", nil)
                          destructiveButtonTitle:nil
                          otherButtonTitles:NSLocalizedString(@"addNote", nil),NSLocalizedString(@"pullBlackTitle", nil),NSLocalizedString(@"pullBlackAndReport", nil),NSLocalizedString(@"viewBlackList", nil),nil];
        }else{
            blockSheet = [[UIActionSheet alloc]
                          initWithTitle:nil
                          delegate:self
                          cancelButtonTitle:NSLocalizedString(@"cancelNotice", nil)
                          destructiveButtonTitle:nil
                          otherButtonTitles:NSLocalizedString(@"pullBlackTitle", nil),NSLocalizedString(@"pullBlackAndReport", nil),NSLocalizedString(@"viewBlackList", nil),nil];
        }
        blockSheet.tag = 1;
        [blockSheet showInView:self.navigationController.view];
        //        [blockSheet showFromTabBar:self.navigationController.tabBarController.tabBar];
        [blockSheet release];
    }
    
    //关注、取消关注
    else if(button.tag-178 == 1)
    {
        //        "guanzhuNotice"="关注功能提示";
        //        "guanzhuMessage"="请注意：用户互相添加关注之后，成为好友关系。";
        
        NSString *title = _linked?NSLocalizedString(@"unlinkButton", nil):NSLocalizedString(@"guanzhuMessage", nil);
        UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:NSLocalizedString(@"guanzhuNotice", nil)
                                                            message:title
                                                           delegate:self cancelButtonTitle:NSLocalizedString(@"cancelNotice", nil) otherButtonTitles:NSLocalizedString(@"confirmNotice", nil), nil];
        [alertView show];
        [alertView release];
    }
    else
    {
        
        if([[UserDefaults valueForKey:@"isNewRegister"] boolValue])
        {
            UIAlertView *alert = [[UIAlertView alloc] initWithTitle:NSLocalizedString(@"benrenP", nil) message:NSLocalizedString(@"shangchuanTouX", nil) delegate:self cancelButtonTitle:NSLocalizedString(@"enterChat", nil) otherButtonTitles:NSLocalizedString(@"fullProfile", nil), nil];
            alert.tag = 2321;
            [alert show];
            [alert release];
        }
        else
        {
            [self gochat];
        }
        
    }
    
}

#pragma mark - 跳转到聊天界面
-(void)gochat
{
    BanBu_ChatViewController *chat = nil;
    for(UIViewController *vc in [self.navigationController viewControllers])
        if([vc isKindOfClass:[BanBu_ChatViewController class]])
        {
            chat = (BanBu_ChatViewController *)vc;
            
            //                NSLog(@"%@ %@",MyAppDataManager.chatuid,[_profile valueForKey:@"userid"]);
            if(![MyAppDataManager.chatuid isEqual:[_profile valueForKey:@"userid"]])
            {
                NSMutableArray *arr = [NSMutableArray arrayWithArray:self.navigationController.viewControllers];
                [arr removeObject:chat];
                self.navigationController.viewControllers = arr;
                chat = nil;
            }
            break;
            
        }
    if(chat)
    {
        [MyAppDataManager readTalkList:[_profile valueForKey:@"userid"] WithNumber:MyAppDataManager.dialogs.count];
        
        chat.smileViewBackup = MyAppDataManager.smileViewBackup;
        [self.navigationController popToViewController:chat animated:YES];
    }
    else
    {
        [MyAppDataManager readTalkList:[_profile valueForKey:@"userid"] WithNumber:5];
        
        chat = [[BanBu_ChatViewController alloc] initWithPeopleProfile:_profile];
        chat.smileViewBackup = MyAppDataManager.smileViewBackup;
        [self.navigationController pushViewController:chat animated:YES];
        [chat release];
    }
    
}
#pragma alertDelegate


- (void)alertView:(UIAlertView *)alertView didDismissWithButtonIndex:(NSInteger)buttonIndex
{
    //    if(alertView.tag == 157334)
    //    {
    //        if(buttonIndex == 1)
    //        {
    //
    //            BanBu_VideoAuthenViewController *video = [[BanBu_VideoAuthenViewController alloc] initWithRegisterVerify:NO];
    //            [self.navigationController pushViewController:video animated:YES];
    //            [video release];
    //        }
    //        return;
    //    }
    //    else
    if(alertView.tag == 2321)
    {
        if(buttonIndex == 0)
        {
            [self gochat];
        }
        else
        {
            BanBu_PersonDataViewController *myProfile1 = [[BanBu_PersonDataViewController alloc] initWithProfile:[UserDefaults valueForKey:MyAppDataManager.useruid]];
            [UserDefaults setValue:[NSNumber numberWithBool:NO] forKey:@"isNewRegister"];//新注册用户
            [self.navigationController pushViewController:myProfile1 animated:YES];
            [myProfile1 release];
        }
        return;
    }
#pragma mark - 添加好友
    if(alertView == greetAlert){
        if(buttonIndex == alertView.firstOtherButtonIndex){
            
            NSMutableDictionary *parDic = [NSMutableDictionary dictionary];
            [parDic setValue:[_profile valueForKey:@"userid"] forKey:LinkTouID];
            [parDic setValue:@"friend" forKey:Action];
            
            [AppComManager getBanBuData:BanBu_Set_Friend_Link par:parDic delegate:self];
            self.navigationController.view.userInteractionEnabled = NO;
            
        }
        return;
    }
    
    else
        
        if(alertView == customAlert){
            if(buttonIndex == alertView.firstOtherButtonIndex)
            {
                NSArray *messageArr = [NSArray arrayWithObjects:NSLocalizedString(@"badMessage", nil),NSLocalizedString(@"badMessage1", nil),NSLocalizedString(@"badMessage2", nil),NSLocalizedString(@"badMessage3", nil), nil];
                NSMutableDictionary *pars = [NSMutableDictionary dictionaryWithCapacity:2];
                [pars setValue:[_profile valueForKey:@"userid"] forKey:ReportTouID];
                
                if(![textView1.text isEqualToString:@""]){
                    NSString *mess = [NSString stringWithFormat:@"%@,%@",[messageArr objectAtIndex:reportMessIndex],textView1.text];
                    
                    [pars setValue:mess forKey:@"saytext"];
                    
                }else{
                    [pars setValue:[messageArr objectAtIndex:reportMessIndex] forKey:@"saytext"];
                    
                }
                [AppComManager getBanBuData:BanBu_Report_User par:pars delegate:self];
                self.navigationController.view.userInteractionEnabled = NO;
                
                _isBlack = YES;
                //NSLog(@"%@",pars);
            }
            return;
        }
#pragma mark - 关注或者取消关注
    if(buttonIndex == alertView.firstOtherButtonIndex)
    {
        NSString *action = _linked?@"unlink":@"link";
        NSMutableDictionary *pars = [NSMutableDictionary dictionaryWithCapacity:2];
        [pars setValue:[_profile valueForKey:@"userid"] forKey:LinkTouID];
        [pars setValue:action forKey:Action];
        [AppComManager getBanBuData:BanBu_Set_Friend_Link par:pars delegate:self];
        self.navigationController.view.userInteractionEnabled = NO;
        _isBlack = NO;
        
        [TKLoadingView showTkloadingAddedTo:self.navigationController.view title:NSLocalizedString(@"chuliNotice", nil) activityAnimated:YES];
    }
    
}

-(void)reportAndPullBlack:(NSString *)message{
    //    NSLog(@"%@",message);
    NSMutableDictionary *pars = [NSMutableDictionary dictionaryWithCapacity:2];
    [pars setValue:[_profile valueForKey:@"userid"] forKey:ReportTouID];
    [pars setValue:message forKey:@"saytext"];
    [AppComManager getBanBuData:BanBu_Report_User par:pars delegate:self];
    self.navigationController.view.userInteractionEnabled = NO;
    [TKLoadingView showTkloadingAddedTo:self.navigationController.view  title:NSLocalizedString(@"chuliNotice", nil) activityAnimated:YES];
    _isBlack = YES;
    
}
/*
 -(void)willPresentAlertView:(UIAlertView *)alertView
 {
 
 
 if(alertView==customAlert)
 {
 CGRect frame=alertView.frame;
 
 frame.origin.y=frame.origin.y-185;
 
 if(frame.size.height ==115){
 frame.size.height=frame.size.height+150;
 
 }
 
 //        frame.size.width=frame.size.width;
 
 alertView.frame=frame;
 
 for(UIView *view in alertView.subviews)
 {
 if(![view isKindOfClass:[UILabel class]])
 {
 
 if(view.tag==1)
 {
 CGRect btnFrame=CGRectMake(30, frame.size.height-55, 105, 40);
 
 view.frame=btnFrame;
 
 }else if(view.tag==2)
 {
 
 CGRect btnFrame2 =CGRectMake(142, frame.size.height-55, 105, 40);
 view.frame = btnFrame2;
 
 
 }
 
 
 }
 
 }
 
 UIView *container = [[UIView alloc] initWithFrame:CGRectMake(20, 40, 250, 80)];
 container.backgroundColor = [UIColor clearColor];
 [self.view addSubview:container];
 
 RadioButton *rb1 = [[RadioButton alloc] initWithGroupId:@"first group" index:0];
 RadioButton *rb2 = [[RadioButton alloc] initWithGroupId:@"first group" index:1];
 RadioButton *rb3 = [[RadioButton alloc] initWithGroupId:@"first group" index:2];
 RadioButton *rb4 = [[RadioButton alloc] initWithGroupId:@"first group" index:3];
 [rb1 handleButtonTap:rb1.button];//自己加的
 rb1.frame = CGRectMake(5,20,22+80,22);
 rb2.frame = CGRectMake(5,50,22+80,22);
 rb3.frame = CGRectMake(115,20,22+120,22);
 rb4.frame = CGRectMake(115,50,22+120,22);
 
 [container addSubview:rb1];
 [container addSubview:rb2];
 [container addSubview:rb3];
 [container addSubview:rb4];
 
 [rb1 release];
 [rb2 release];
 [rb3 release];
 [rb4 release];
 [alertView addSubview:container];
 
 UILabel *label1 =[[UILabel alloc] initWithFrame:CGRectMake(35, 20, 80, 20)];
 label1.backgroundColor = [UIColor clearColor];
 label1.textColor = [UIColor whiteColor];
 label1.text = NSLocalizedString(@"badMessage", nil);
 [container addSubview:label1];
 [label1 release];
 
 UILabel *label2 =[[UILabel alloc] initWithFrame:CGRectMake(35, 50, 80, 20)];
 label2.backgroundColor = [UIColor clearColor];
 label2.text = NSLocalizedString(@"badMessage1", nil);
 label2.textColor = [UIColor whiteColor];
 
 [container addSubview:label2];
 [label2 release];
 
 UILabel *label3 =[[UILabel alloc] initWithFrame:CGRectMake(145, 20, 120, 20)];
 label3.backgroundColor = [UIColor clearColor];
 label3.text = NSLocalizedString(@"badMessage2", nil);
 label3.textColor = [UIColor whiteColor];
 
 [container addSubview:label3];
 [label3 release];
 
 UILabel *label4 =[[UILabel alloc] initWithFrame:CGRectMake(145, 50, 120, 20)];
 label4.backgroundColor = [UIColor clearColor];
 label4.text = NSLocalizedString(@"badMessage3", nil);
 label4.textColor = [UIColor whiteColor];
 
 [container addSubview:label4];
 [label4 release];
 
 [RadioButton addObserverForGroupId:@"first group" observer:self];
 
 // 放留言的内容：
 
 
 textView1=[[UITextField alloc]initWithFrame:CGRectMake(20, 120, 250, 80)];
 
 //        textView1.bounces=YES;
 textView1.backgroundColor = [UIColor whiteColor];
 textView1.delegate=self;
 textView1.text = @"";
 textView1.layer.cornerRadius=5;
 textView1.layer.borderColor = [[UIColor grayColor]CGColor];
 textView1.layer.borderWidth = 3;
 textView1.font=[UIFont systemFontOfSize:18];
 textView1.returnKeyType = UIReturnKeyDone;
 textView1.textColor=[UIColor grayColor];
 textView1.placeholder = NSLocalizedString(@"badDetailMessage", nil);
 //        textView1.text=NSLocalizedString(@"textWord", nil);
 
 [alertView addSubview:textView1];
 
 [textView1 release];
 
 
 
 }
 
 
 }
 
 
 */
-(void)radioButtonSelectedAtIndex:(NSUInteger)index inGroup:(NSString *)groupId{
    reportMessIndex = index;
    //NSLog(@"changed to %d in %@",index,groupId);
}

-(BOOL)textFieldShouldReturn:(UITextField *)textField{
    if([textField isFirstResponder]){
        [textField resignFirstResponder];
    }
    
    return  YES;
}

-(void)changeNameAction:(NSString *)noteName
{
    NSMutableDictionary *parDic = [NSMutableDictionary dictionary];
    [parDic setValue:[_profile valueForKey:@"userid"] forKey:@"friendid"];
    [parDic setValue:[MyAppDataManager IsMinGanWord:noteName] forKey:@"fname"];
    [AppComManager getBanBuData:BanBu_Set_FriendName par:parDic delegate:self];
    self.navigationController.view.userInteractionEnabled = NO;
}

#pragma mark - ActionSheet delegate

- (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex
{
    if(!actionSheet.tag-178 == 1)
    {
        
    }
    else
    {
        if(_kind == 2||_kind == 0){
            
            if(buttonIndex == 0)
            {
                CATransition *transition = [CATransition animation];
                transition.duration = 0.5f;
                transition.delegate = self;
                transition.fillMode = kCAFillModeForwards;
                transition.timingFunction = UIViewAnimationCurveEaseInOut;
                transition.type = @"fade";
                transition.removedOnCompletion = NO;
                [self.navigationController.view.layer removeAnimationForKey:@"reveal"];
                
                [self.navigationController.view.layer addAnimation:transition forKey:@"reveal"];
                aNote = [[BanBu_NoteView alloc]initWithFrame:self.navigationController.view.bounds andTitle:[MyAppDataManager theRevisedName:[_profile valueForKey:@"pname"] andUID:[_profile valueForKey:@"userid"]]];
                aNote.delegate = self;
                [self.navigationController.view addSubview:aNote];
                [aNote release];
            }
            if(buttonIndex == 1)
            {
#pragma mark - 加入黑名单
                if(!_isBlack)
                {
                    NSString *action = @"black";
                    NSMutableDictionary *pars = [NSMutableDictionary dictionary];
                    [pars setValue:[_profile valueForKey:@"userid"] forKey:LinkTouID];
                    [pars setValue:action forKey:Action];
                    [AppComManager getBanBuData:BanBu_Set_Friend_Link par:pars delegate:self];
                    self.navigationController.view.userInteractionEnabled = NO;
                    
                    _isBlack = YES;
                }
                else
                {
                    [TKLoadingView showTkloadingAddedTo:self.navigationController.view title:NSLocalizedString(@"pullBlackOK", nil) activityAnimated:NO duration:1.0];
                }
            }
            else if(buttonIndex == 2)
            {
                aReportView = [[BanBu_ReportView alloc]initWithFrame:CGRectMake(0, 0, 320, __MainScreen_Height+20) andType:REPORT_USER];
                aReportView.delegate = self;
                [self.navigationController.view addSubview:aReportView];
                [aReportView release];
            }
            else if(buttonIndex == 3)
            {
                BanBu_BlacklistViewController *black = [[BanBu_BlacklistViewController alloc]init];
                [self.navigationController pushViewController:black animated:YES];
                [black release];
            }
        }
        else
        {
            if(buttonIndex == 0)
            {
#pragma mark - 加入黑名单
                if(!_isBlack)
                {
                    NSString *action = @"black";
                    NSMutableDictionary *pars = [NSMutableDictionary dictionary];
                    [pars setValue:[_profile valueForKey:@"userid"] forKey:LinkTouID];
                    [pars setValue:action forKey:Action];
                    [AppComManager getBanBuData:BanBu_Set_Friend_Link par:pars delegate:self];
                    self.navigationController.view.userInteractionEnabled = NO;
                    [TKLoadingView showTkloadingAddedTo:self.navigationController.view title:NSLocalizedString(@"chuliNotice", nil) activityAnimated:YES];
                    _isBlack = YES;
                }
                else
                {
                    [TKLoadingView showTkloadingAddedTo:self.navigationController.view  title:NSLocalizedString(@"pullBlackOK", nil) activityAnimated:NO duration:1.0];
                }
            }
            if(buttonIndex == 1)
            {
                aReportView = [[BanBu_ReportView alloc]initWithFrame:CGRectMake(0, 0, 320, __MainScreen_Height+20) andType:REPORT_USER];
                aReportView.delegate = self;
                [self.navigationController.view addSubview:aReportView];
                [aReportView release];
            }
            else if(buttonIndex == 2)
            {
                BanBu_BlacklistViewController *black = [[BanBu_BlacklistViewController alloc]init];
                [self.navigationController pushViewController:black animated:YES];
                [black release];
            }
        }
    }
}

-(void)updateFansButtonNumberWithAddNum:(NSInteger )_addNum
{
    UIButton *btn = (UIButton *)[self.tableView viewWithTag:22114];
    NSInteger num = [btn.titleLabel.text integerValue];
    num = num+_addNum;
    [btn setTitle:[NSString stringWithFormat:@"%d",num] forState:UIControlStateNormal];
}
- (void)banbuRequestDidFinished:(NSDictionary *)resDic error:(NSError *)error
{
    NSLog(@"%@",resDic);
    self.navigationController.view.userInteractionEnabled = YES;
    [TKLoadingView dismissTkFromView:self.navigationController.view animated:YES afterShow:0.0];
    if(error)
    {
        if([error.domain isEqualToString:BanBuDataformatError])
        {
            [TKLoadingView showTkloadingAddedTo:self.navigationController.view title:NSLocalizedString(@"network_error", nil) activityAnimated:NO duration:2.0];
        }
        else
        {
            [TKLoadingView showTkloadingAddedTo:self.navigationController.view title:NSLocalizedString(@"network_error", nil) activityAnimated:NO duration:2.0];
        }
        _isBlack = !_isBlack;
        return;
    }
    if([AppComManager respondsDic:resDic isFunctionData:BanBu_Send_Verify_Invite_Touser])
    {
        if([[resDic valueForKey:@"ok"] boolValue])
        {
            [TKLoadingView showTkloadingAddedTo:self.navigationController.view title:NSLocalizedString(@"sendS", nil) activityAnimated:NO duration:1];
        }
        else
        {
            if([[resDic allKeys] indexOfObject:@"error"] != NSNotFound)
            {
                [TKLoadingView showTkloadingAddedTo:self.navigationController.view title:[MyAppDataManager IsInternationalLanguage:[resDic valueForKey:@"error"]] activityAnimated:NO duration:1];
            }
            else
            {
                [TKLoadingView showTkloadingAddedTo:self.navigationController.view title:NSLocalizedString(@"senfF", nil) activityAnimated:NO duration:1];
            }
        }
    }
    if([AppComManager respondsDic:resDic isFunctionData:BanBu_Get_User_Sns_Idlist])
    {
        [_socialInfo removeAllObjects];
        //2014年10月09日18:18:33 by yinlinlin 判断字典类型，有可能返回的snslist不是字典类型
        if ([[resDic valueForKey:@"snslist"] isKindOfClass:[NSDictionary class]])
        {
            [_socialInfo addEntriesFromDictionary:[resDic valueForKey:@"snslist"]];
            [self.tableView reloadData];
        }
    }
    if([AppComManager respondsDic:resDic isFunctionData:BanBu_Set_Friend_Link])
    {
        NSLog(@"%@",resDic);
        if([[resDic valueForKey:@"ok"]boolValue])
        {
            
            NSNumber * number = [NSNumber numberWithInt:[[resDic valueForKey:@"getscore"] integerValue]];
            dispatch_async(dispatch_get_main_queue(), ^{
                [MyAppDataManager showGoldView:number andView:self.navigationController.view];
            });
            
            NSMutableDictionary *uidDic = [NSMutableDictionary dictionaryWithDictionary:[UserDefaults valueForKey:MyAppDataManager.useruid]];
            [uidDic setValue:[resDic valueForKey:@"friendlist"] forKey:FriendShip];
            [uidDic setValue:[resDic valueForKey:@"friendsum"] forKey:@"friendsum"];
            [UserDefaults setValue:uidDic forKey:MyAppDataManager.useruid];
            [UserDefaults synchronize];
#pragma mark - 加入黑名单成功
            if (_isBlack)
            {
                [TKLoadingView showTkloadingAddedTo:self.navigationController.view title:NSLocalizedString(@"pullBlackOK", nil) activityAnimated:NO duration:1.0];
                if (_linked)
                {
                    [_linkButton setBackgroundImage:[ThemeManager getThemeImage:@"button_addfriend.png"] forState:UIControlStateNormal];
                    [(UILabel *)[_linkButton viewWithTag:236] setText:NSLocalizedString(@"addLink", nil)];
                    for(BanBu_HisFriendViewController *viewController in self.navigationController.viewControllers)
                    {
                        if([viewController isKindOfClass:[BanBu_HisFriendViewController class]])
                        {
                            NSMutableDictionary *hisFriendDic = [NSMutableDictionary dictionaryWithDictionary:[viewController.hisFriends objectAtIndex:viewController.linkRow]];
                            [hisFriendDic setValue:[NSNumber numberWithBool:!_linked] forKey:@"linked"];
                            
                            [viewController.hisFriends replaceObjectAtIndex:viewController.linkRow withObject:hisFriendDic];
                            [viewController.tableView reloadRowsAtIndexPaths:[NSArray arrayWithObject:[NSIndexPath indexPathForRow:viewController.linkRow inSection:0]] withRowAnimation:UITableViewRowAnimationNone];
                        }
                    }
                    
                }
            }
#pragma mark - 取消关注成功
            else if (_linked)
            {
                [TKLoadingView dismissTkFromView:self.navigationController.view animated:NO afterShow:0];
                [TKLoadingView showTkloadingAddedTo:self.navigationController.view title:!_linked?NSLocalizedString(@"linkSuccess", nil):NSLocalizedString(@"unlinkSuccess", nil) activityAnimated:NO duration:1.0];
                [_linkButton setBackgroundImage:[ThemeManager getThemeImage:@"button_addfriend.png"] forState:UIControlStateNormal];
                [(UILabel *)[_linkButton viewWithTag:236] setText:NSLocalizedString(@"addLink", nil)];
                for(BanBu_HisFriendViewController *viewController in self.navigationController.viewControllers)
                {
                    if([viewController isKindOfClass:[BanBu_HisFriendViewController class]])
                    {
                        NSMutableDictionary *hisFriendDic = [NSMutableDictionary dictionaryWithDictionary:[viewController.hisFriends objectAtIndex:viewController.linkRow]];
                        [hisFriendDic setValue:[NSNumber numberWithBool:!_linked] forKey:@"linked"];
                        
                        [viewController.hisFriends replaceObjectAtIndex:viewController.linkRow withObject:hisFriendDic];
                        [viewController.tableView reloadRowsAtIndexPaths:[NSArray arrayWithObject:[NSIndexPath indexPathForRow:viewController.linkRow inSection:0]] withRowAnimation:UITableViewRowAnimationNone];
                    }
                }
                
                
            }
#pragma mark - 关注或添加好友成功
            else
            {
                [TKLoadingView dismissTkFromView:self.navigationController.view animated:NO afterShow:0];
                [TKLoadingView showTkloadingAddedTo:self.navigationController.view title:!_linked?NSLocalizedString(@"linkSuccess", nil):NSLocalizedString(@"unlinkSuccess", nil) activityAnimated:NO duration:1.0];
                [_linkButton setBackgroundImage:[ThemeManager getThemeImage:@"button_delbuddy.png"] forState:UIControlStateNormal];
                [(UILabel *)[_linkButton viewWithTag:236] setText:NSLocalizedString(@"delLink", nil)];
                for(BanBu_HisFriendViewController *viewController in self.navigationController.viewControllers)
                {
                    if([viewController isKindOfClass:[BanBu_HisFriendViewController class]])
                    {
                        NSMutableDictionary *hisFriendDic = [NSMutableDictionary dictionaryWithDictionary:[viewController.hisFriends objectAtIndex:viewController.linkRow]];
                        [hisFriendDic setValue:[NSNumber numberWithBool:!_linked] forKey:@"linked"];
                        
                        [viewController.hisFriends replaceObjectAtIndex:viewController.linkRow withObject:hisFriendDic];
                        [viewController.tableView reloadRowsAtIndexPaths:[NSArray arrayWithObject:[NSIndexPath indexPathForRow:viewController.linkRow inSection:0]] withRowAnimation:UITableViewRowAnimationNone];
                    }
                }
                
            }
            //判断好友关系
            NSString *fensi = [[[UserDefaults valueForKey:MyAppDataManager.useruid]valueForKey:FriendShip] valueForKey:@"f"];
            NSString *guanzhu = [[[UserDefaults valueForKey:MyAppDataManager.useruid]valueForKey:FriendShip] valueForKey:@"g"];
            NSString *friend = [[[UserDefaults valueForKey:MyAppDataManager.useruid]valueForKey:FriendShip] valueForKey:@"h"];
            NSString *black = [[[UserDefaults valueForKey:MyAppDataManager.useruid]valueForKey:FriendShip] valueForKey:@"x"];
            if([friend rangeOfString:[_profile valueForKey:@"userid"]].location != NSNotFound)
            {
                _linked = YES;
                _kind = 2;
                double delayInSeconds = 0.5;
                dispatch_time_t popTime = dispatch_time(DISPATCH_TIME_NOW, (int64_t)(delayInSeconds * NSEC_PER_SEC));
                dispatch_after(popTime, dispatch_get_main_queue(), ^(void){
                    if(self.view)
                    {
                        
                        CATransition *transition = [CATransition animation];
                        transition.duration = 0.5f;
                        transition.delegate = self;
                        transition.fillMode = kCAFillModeForwards;
                        transition.timingFunction = UIViewAnimationCurveEaseInOut;
                        transition.type = @"fade";
                        transition.removedOnCompletion = NO;
                        [self.navigationController.view.layer removeAnimationForKey:@"reveal"];
                        [self.navigationController.view.layer addAnimation:transition forKey:@"reveal"];
                        
                        aNote = [[BanBu_NoteView alloc]initWithFrame:self.navigationController.view.bounds andTitle:[MyAppDataManager theRevisedName:[_profile valueForKey:@"pname"] andUID:[_profile valueForKey:@"userid"]]];
                        aNote.delegate = self;
                        [self.navigationController.view addSubview:aNote];
                        [aNote release];
                        
                    }
                    
                    
                    
                });
                
                
                
            }
            else if([guanzhu rangeOfString:[_profile valueForKey:@"userid"]].location != NSNotFound)
            {
                _linked = YES;
                _kind = 0;
                double delayInSeconds = 0.5;
                dispatch_time_t popTime = dispatch_time(DISPATCH_TIME_NOW, (int64_t)(delayInSeconds * NSEC_PER_SEC));
                dispatch_after(popTime, dispatch_get_main_queue(), ^(void){
                    if(self.view)
                    {
                        
                        CATransition *transition = [CATransition animation];
                        transition.duration = 0.5f;
                        transition.delegate = self;
                        transition.fillMode = kCAFillModeForwards;
                        transition.timingFunction = UIViewAnimationCurveEaseInOut;
                        transition.type = @"fade";
                        transition.removedOnCompletion = NO;
                        [self.navigationController.view.layer removeAnimationForKey:@"reveal"];
                        [self.navigationController.view.layer addAnimation:transition forKey:@"reveal"];
                        
                        aNote = [[BanBu_NoteView alloc]initWithFrame:self.navigationController.view.bounds andTitle:[MyAppDataManager theRevisedName:[_profile valueForKey:@"pname"] andUID:[_profile valueForKey:@"userid"]]];
                        aNote.delegate = self;
                        [self.navigationController.view addSubview:aNote];
                        [aNote release];
                        
                    }
                    
                    
                    
                });
                
                
            }
            else if([fensi rangeOfString:[_profile valueForKey:@"userid"]].location != NSNotFound)
            {
                _linked = NO;
                _kind = 1;
            }
            else if([black rangeOfString:[_profile valueForKey:@"userid"]].location != NSNotFound)
            {
                _linked = NO;
                _kind = 3;
            }
            else
            {
                _linked = NO;
                _kind = 4;
            }
            
            [self.tableView reloadSections:[NSIndexSet indexSetWithIndex:isHaveGRJS?4:3] withRowAnimation:UITableViewRowAnimationNone];
            //2014年11月17日09:41:50 By yinlinlin 实时更新好友关系
            NSIndexPath * relationIndex = [NSIndexPath indexPathForRow:2 inSection:1];
            UITableViewCell * cell = [self.tableView cellForRowAtIndexPath:relationIndex];
            NSArray *frindshipArr = [NSArray arrayWithObjects:NSLocalizedString(@"friendShip", nil),NSLocalizedString(@"friendShip1", nil),NSLocalizedString(@"friendShip2", nil),NSLocalizedString(@"friendShip3", nil),NSLocalizedString(@"friendShip4", nil),NSLocalizedString(@"friendShip5", nil), nil];
            cell.detailTextLabel.text =  [frindshipArr objectAtIndex:_kind];
            //2014年11月17日09:42:24 by yinlinlin 修改完成
            [MyAppDataManager deleteBlackDialog:[[resDic valueForKey:@"friendlist"] valueForKey:@"x"]];
            
        }
        else
        {
            UIAlertView *alert = [[UIAlertView alloc] initWithTitle:NSLocalizedString(@"noticeNotice", nil) message:[MyAppDataManager IsInternationalLanguage:[resDic valueForKey:@"error"]] delegate:nil cancelButtonTitle:NSLocalizedString(@"确定", nil) otherButtonTitles:nil, nil];
            [alert show];
            [alert release];
            //            [TKLoadingView showTkloadingAddedTo:self.navigationController.view title:[MyAppDataManager IsInternationalLanguage:[resDic valueForKey:@"error"]] activityAnimated:NO duration:1.0];
        }
    }
    else if([AppComManager respondsDic:resDic isFunctionData:BanBu_Report_User])
    {
        
        if([[resDic valueForKey:@"ok"]boolValue])
        {
            NSMutableDictionary *uidDic = [NSMutableDictionary dictionaryWithDictionary:[UserDefaults valueForKey:MyAppDataManager.useruid]];
            [uidDic setValue:[resDic valueForKey:@"friendlist"] forKey:FriendShip];
            [UserDefaults setValue:uidDic forKey:MyAppDataManager.useruid];
            [UserDefaults synchronize];
            
            if(!_isBlack || _linked ==YES)
            {
                if(!_linked)
                {
                    [_linkButton setBackgroundImage:[ThemeManager getThemeImage:@"button_delbuddy.png"] forState:UIControlStateNormal];
                    [(UILabel *)[_linkButton viewWithTag:236] setText:NSLocalizedString(@"deLink", nil)];
                }
                else
                {
                    [_linkButton setBackgroundImage:[ThemeManager getThemeImage:@"button_addfriend.png"] forState:UIControlStateNormal];
                    [(UILabel *)[_linkButton viewWithTag:236] setText:NSLocalizedString(@"addLink", nil)];
                }
                _linked = !_linked;
                if(!_linked && _isBlack)
                {
                    [TKLoadingView showTkloadingAddedTo:self.navigationController.view title:NSLocalizedString(@"blackAndReportOK", nil) activityAnimated:NO duration:1.0];
                }
            }
            else
            {
                [TKLoadingView showTkloadingAddedTo:self.navigationController.view title:NSLocalizedString(@"blackAndReportOK", nil) activityAnimated:NO duration:1.0];
            }
            //显示黑名单
            _kind = 3; _linked = NO;
            
            [self.tableView reloadSections:[NSIndexSet indexSetWithIndex:isHaveGRJS?4:3] withRowAnimation:UITableViewRowAnimationNone];
            
            [MyAppDataManager deleteBlackDialog:[[resDic valueForKey:@"friendlist"] valueForKey:@"x"]];
        }
        else
        {
            [TKLoadingView showTkloadingAddedTo:self.navigationController.view title:[resDic valueForKey:@"error"] activityAnimated:NO duration:1.0];
        }
    }
    else if([AppComManager respondsDic:resDic isFunctionData:BanBu_Get_Friend_FriendDo])
    {
        if([[resDic valueForKey:@"ok"]boolValue])
        {
            for(int i=0;i<[[resDic valueForKey:@"list"]count];i++)
            {
                NSMutableDictionary *aDic = [NSMutableDictionary dictionaryWithDictionary:[[resDic valueForKey:@"list"] objectAtIndex:i]];
                
                NSMutableDictionary *mcontentDic = [NSMutableDictionary dictionaryWithDictionary:[AppComManager getAMsgFrom64String:[aDic valueForKey:@"mcontent"]]];
                
                [mcontentDic setValue:[MyAppDataManager IsInternationalLanguage:[mcontentDic valueForKey:@"saytext"]] forKey:@"saytext"];
                [aDic setValue:mcontentDic forKey:@"mcontent"];
                [self.userActions addObject:aDic];
            }
            [self.tableView reloadData];
        }
        else
        {
            if([[resDic valueForKey:@"error"] isEqualToString:@"__loginidinvalid__"])
            {
                [self.navigationController popToRootViewControllerAnimated:NO];
            }
        }
    }
    else if([AppComManager respondsDic:resDic isFunctionData:BanBu_Set_FriendName])
    {
        if([[resDic valueForKey:@"ok"]boolValue])
        {
            NSMutableDictionary *uidDic = [NSMutableDictionary dictionaryWithDictionary:[UserDefaults valueForKey:MyAppDataManager.useruid]];
            [uidDic setValue:[resDic valueForKey:@"list"] forKey:@"renameflist"];
            [UserDefaults setValue:uidDic forKey:MyAppDataManager.useruid];
            [UserDefaults synchronize];
            //            [aNote removeFromSuperview];
            self.title =  [MyAppDataManager IsInternationalLanguage:[MyAppDataManager theRevisedName:[_profile valueForKey:@"pname"] andUID:[_profile valueForKey:@"userid"]]];
        }
        else
        {
            [TKLoadingView showTkloadingAddedTo:self.navigationController.view title:[MyAppDataManager IsInternationalLanguage:[resDic valueForKey:@"error"]] activityAnimated:NO duration:1.0];
        }
    }
    //蛋疼的更新
    else if([AppComManager respondsDic:resDic isFunctionData:BanBu_Get_User_info_v2])
    {
        if([[resDic valueForKey:@"ok"]boolValue])
        {
            NSMutableDictionary *userInfor = [NSMutableDictionary dictionaryWithDictionary:resDic];
            [userInfor removeObjectForKey:@"fc"];
            [userInfor removeObjectForKey:@"actioncount"];
            NSDictionary *dic = [NSDictionary dictionaryWithObjectsAndKeys:userInfor,keyPersonalInfo,[resDic valueForKey:@"userid"],@"userid",nil];
            
            __block NSMutableArray *saveArr = [[NSMutableArray alloc] initWithObjects:dic, nil];
            
            dispatch_queue_t queue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0);
            dispatch_async(queue, ^{
                [MyAppDataManager writePersonalDataToDB:saveArr];
                [saveArr release];
                //                NSLog(@"%@",[MyAppDataManager getPersonalDataOfUserid:[NSArray arrayWithObject:@"143661"]]);
                //                NSArray *a = [MyAppDataManager getPersonalDataOfUserid:[NSArray arrayWithObject:[_profile valueForKey:@"userid"]]];
                
            });
            //            [self setBadgeValue:[resDic valueForKey:@"actioncount"]];
            //            NSString *badgeValue = [resDic valueForKey:@"actioncount"];
            //            float width = [badgeValue sizeWithFont:[UIFont boldSystemFontOfSize:14]].width+12;
            //
            //            [_badgeView setFrame:CGRectMake(-width/3, -2, width, 20)];
            //            _badgeView.badgeString = badgeValue;
            //
            //            if(![_badgeView.badgeString length]||[_badgeView.badgeString isEqualToString:@"0"])
            //            {
            //                _badgeView.hidden = YES;
            //            }
            //            else
            //                _badgeView.hidden = NO;
            //        你这么记
            /*
             S iong
             D iang
             ; ing
             Q iq
             w ia
             i i
             m ian
             
             这是所有i打头的
             再记住a打头的e打头的u打头的a打头的就完了
             */
            NSMutableDictionary  *parDic = [[NSMutableDictionary alloc] initWithDictionary:resDic];
            //            if([[parDic valueForKey:@"ltime"] rangeOfString:@"-"].location != NSNotFound)
            //            {
            [parDic setValue:[MyAppDataManager getTheLastOnlineTime:[parDic valueForKey:@"ltime"]] forKey:@"ltime"];
            //            }
            [self setProfile:parDic];
            //            _profile = [[NSMutableDictionary alloc]initWithDictionary:parDic];
            //            _photoView.uface = [_profile valueForKey:@"uface"];
            //            _photoView.myPhotos = [_profile valueForKey:@"facelist"];
            //            if([[_profile allKeys] indexOfObject:@"userlevel"] != NSNotFound)
            //                _photoView.isVIP = [[_profile valueForKey:@"userlevel"] integerValue]>0;
            //            else
            //                _photoView.isVIP = NO;
            
            
        }
    }
    else if ([AppComManager respondsDic:resDic isFunctionData:BanBu_Get_Actioncount_Byfuid_V2])
    {
        //        NSLog(@"%@",resDic);
        if([[resDic valueForKey:@"ok"] boolValue])
        {
            [self setBadgeValue:[resDic valueForKey:@"actioncount"]];
        }
    }
}

-(void)setBadgeValue:(NSString *)_value
{
    float width = [_value sizeWithFont:[UIFont boldSystemFontOfSize:14]].width+12;
    
    [_badgeView setFrame:CGRectMake(-width/3, -2, width, 20)];
    _badgeView.badgeString = _value;
    
    if(![_badgeView.badgeString length]||[_badgeView.badgeString isEqualToString:@"0"])
    {
        _badgeView.hidden = YES;
    }
    else
        _badgeView.hidden = NO;
}
+(UIView *)creatHeaderView:(NSDictionary *)peopleProfile
{
    UIView  *headView = [[[UILabel alloc] initWithFrame:CGRectMake(0, 0, 320, 30)] autorelease];
    headView.backgroundColor = [UIColor colorWithRed:255.0/255 green:250.0/255 blue:240.0/255 alpha:1.0];
    BanBu_ImageView *img = [[[BanBu_ImageView alloc] initWithBackGroundImageType:UIImageViewCreatTypeCell] autorelease];
    img.frame = CGRectMake(0, 0, 320, 30);
    [headView addSubview:img];
    
    UILabel *sexLabel = [[UILabel alloc] initWithFrame:CGRectMake(10,5,20,20)];
    sexLabel.font = [UIFont systemFontOfSize:14];
    sexLabel.textAlignment = kTextAlignmentCenter;
    sexLabel.textColor = [UIColor whiteColor];
    sexLabel.layer.cornerRadius = 4.0f;
    if([[peopleProfile valueForKey:@"gender" ] isEqualToString:@"m"])
    {
        sexLabel.backgroundColor = [UIColor colorWithRed:103.0/255 green:187.0/255 blue:1.0 alpha:1.0];
        sexLabel.text = @"♂";
    }
    else
    {
        sexLabel.backgroundColor = [UIColor colorWithRed:253.0/255 green:163.0/255 blue:200.0 alpha:1.0];
        sexLabel.text = @"♀";
    }
    [headView addSubview:sexLabel];
    [sexLabel release];
    if([[peopleProfile valueForKey:@"verify"] boolValue])
    {
        NSString *verifypath = [[NSBundle mainBundle] pathForResource:@"verify_card" ofType:@"png"];
        UIImageView * _verify = [[UIImageView alloc]initWithImage:[UIImage imageWithContentsOfFile:verifypath]];
        _verify.frame = CGRectMake(35,5, 20, 20);
        //    _verify.backgroundColor = [UIColor redColor];
        [headView addSubview:_verify];
        [_verify release];
    }
    
    //
    
    UILabel *titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(60, 0, 100, 30)];
    titleLabel.font = [UIFont systemFontOfSize:14];
    titleLabel.backgroundColor = [UIColor clearColor];
    titleLabel.textColor = [UIColor colorWithRed:56.0/255 green:84.0/255 blue:135.0/255 alpha:1.0];
    titleLabel.text = [NSString stringWithFormat:@"%@ %@",[MyAppDataManager IsInternationalLanguage:[peopleProfile valueForKey:@"sstar"]],[peopleProfile valueForKey:@"oldyears"]];
    [headView addSubview:titleLabel];
    [titleLabel release];
    
    UILabel *distanceLabel = [[UILabel alloc] initWithFrame:CGRectMake(150, 0, 160, 30)];
    distanceLabel.font = [UIFont systemFontOfSize:14];
    distanceLabel.backgroundColor = [UIColor clearColor];
    
    distanceLabel.textColor = [UIColor colorWithRed:56.0/255 green:84.0/255 blue:135.0/255 alpha:1.0];
    distanceLabel.textAlignment = kTextAlignmentRight;
    
    if(![[peopleProfile allKeys] containsObject:@"dmeter"] || ![[peopleProfile allKeys] containsObject:@"ltime"])
    {
    }
    else
    {
        NSString *interLtime = [MyAppDataManager IsInternationalLanguage:[peopleProfile valueForKey:@"ltime"]];
        NSString *interDmeter = [MyAppDataManager IsInternationalLanguage:[peopleProfile valueForKey:@"dmeter"]];
        CGFloat btnLen = [interLtime sizeWithFont:[UIFont systemFontOfSize:14] constrainedToSize:CGSizeMake(100, 30)].width;
        CGFloat btnLen1 = [interDmeter sizeWithFont:[UIFont systemFontOfSize:14] constrainedToSize:CGSizeMake(100, 30)].width;
        UILabel *ltimeLabel = [[UILabel alloc]initWithFrame:CGRectMake(310-btnLen, 0, btnLen, 30)];
        ltimeLabel.text = interLtime;
        ltimeLabel.font = [UIFont systemFontOfSize:14];
        ltimeLabel.backgroundColor = [UIColor clearColor];
        ltimeLabel.textColor = [UIColor colorWithRed:56.0/255 green:84.0/255 blue:135.0/255 alpha:1.0];
        [headView addSubview:ltimeLabel];
        [ltimeLabel release];
        UIImageView *ltimeImageView = [[UIImageView alloc]initWithFrame:CGRectMake(ltimeLabel.frame.origin.x-30+6, 3+2, 20, 20)];
        ltimeImageView.image = [UIImage imageNamed:@"ic_user_loctime.png"];
        [headView addSubview:ltimeImageView];
        [ltimeImageView release];
        
        UILabel *dmeterLabel = [[UILabel alloc]initWithFrame:CGRectMake(ltimeImageView.frame.origin.x-btnLen1-5, 0, btnLen1, 30)];
        dmeterLabel.text = interDmeter;
        dmeterLabel.font = [UIFont systemFontOfSize:14];
        dmeterLabel.backgroundColor = [UIColor clearColor];
        dmeterLabel.textColor = [UIColor colorWithRed:56.0/255 green:84.0/255 blue:135.0/255 alpha:1.0];
        [headView addSubview:dmeterLabel];
        [dmeterLabel release];
        UIImageView *dmeterImageView = [[UIImageView alloc]initWithFrame:CGRectMake(dmeterLabel.frame.origin.x-27+6, 3+2, 20, 20)];
        dmeterImageView.image = [UIImage imageNamed:@"ic_user_location.png"];
        [headView addSubview:dmeterImageView];
        [dmeterImageView release];
    }
    [headView addSubview:distanceLabel];
    [distanceLabel release];
    
    UIView *lineView = [[UIView alloc] initWithFrame:CGRectMake(0, 29, 320, 1.0)];
    lineView.backgroundColor = [UIColor colorWithRed:224.0/255 green:224.0/255 blue:224.0/255 alpha:1.0];
    [headView addSubview:lineView];
    [lineView release];
    return headView;
}
- (void) performPublishAction:(void (^)(void)) action
{
    if ([FBSession.activeSession.permissions indexOfObject:@"publish_actions"] == NSNotFound)
    {
    }
    else
    {
        action();
    }
}

-(void)seeHisFriend:(UIButton *)sender
{
    BanBu_HisFriendViewController *hisfriend = [[BanBu_HisFriendViewController alloc] init];
    hisfriend.userid = [_profile valueForKey:@"userid"];
    if(sender.tag == 22113)
    {
        hisfriend.relationShip = @"g";
    }
    else
    {
        hisfriend.relationShip = @"f";
    }
    [self.navigationController pushViewController:hisfriend animated:YES];
    //    [hisfriend release];
}

@end